<template>
  <div
    style="
      background-color: #fff;
      padding: 20px;
      box-sizing: border-box;
      min-height: calc(100vh - 100px);
    "
  >
    <div>
      <div class="b" style="font-size: 18px">历史药历</div>
      <Back style="margin-top: 8px"/>
    </div>
    <el-table
      v-loading="loading"
      :data="medicationAdvisoryList"
      @selection-change="handleSelectionChange"
      border
    >
      <el-table-column label="序号" type="index" width="50" align="center">
      </el-table-column>
      <el-table-column label="患者姓名" align="center" prop="patientName"/>
      <el-table-column label="入院时间" align="center" prop="admissionTime">
      </el-table-column>
      <el-table-column label="出院时间" align="center" prop="dischargeTime">
      </el-table-column>
      <el-table-column label="主管医生" align="center" prop="doctorName"/>
      <el-table-column
        label="操作"
        width="220"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleUpdate(scope.row)"
          >查看药历
          </el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除
          </el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            :loading="downAllyaoLiXiaoLoading"
            @click="downyaoLi(scope.row)"
          >下载
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改用药咨询对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1100px"
      append-to-body
    >
      <!-- 药历首页 -->
      <div v-loading="dataloading">
        <h2 style="text-align: center; font-weight: 900">药历首页</h2>
        <div class="mb10 r" style="justify-content: space-between">
          <div>
            <span class="headTxt">病区：</span>
            <span class="value">
              <treeselect
                style="width: 350px"
                disabled
                v-model="form.patientBaseInfoVo.deptId"
                :options="deptOptions"
                :show-count="true"
                placeholder=""
              />
            </span>
          </div>
          <div>
            <span class="headTxt">病案号：</span
            ><span class="value" style="height: 30px; width: 110px">{{
              form.patientBaseInfoVo.medicareNo
            }}</span>
          </div>
          <div>
            <span class="headTxt">床号：</span
            ><span class="value" style="height: 30px; width: 110px">{{
              form.patientBaseInfoVo.bedNo
            }}</span>
          </div>
          <div>
            <span class="headTxt">监护分级结果：</span
            ><span class="value" style="height: 30px; width: 110px">{{
              form.patientBaseInfoVo.guardianLevel == '0'
                ? '一级'
                : form.patientBaseInfoVo.guardianLevel == '1'
                ? '二级'
                : '三级'
            }}</span>
          </div>
        </div>

        <table
          border="1"
          cellspacing="0"
          align="center"
          bordercolor="#ccc"
          width="1051px"
        >
          <tr>
            <th align="center">姓名</th>
            <td align="center">
              {{ form.patientBaseInfoVo.patientName }}
            </td>
            <th align="center">性别</th>
            <td align="center">
              {{
                form.patientBaseInfoVo.patientSex == '1'
                  ? '男'
                  : form.patientBaseInfoVo.patientSex == '2'
                  ? '女'
                  : ''
              }}
            </td>
            <th width="60" align="center">年龄</th>
            <td align="center" width="105">
              {{ form.patientBaseInfoVo.patientAge }}
            </td>
            <th width="60" align="center">职业</th>
            <td align="center">
              {{
                form.patientBaseInfoVo.patientProfession
                  ? form.patientBaseInfoVo.patientProfession
                  : '无'
              }}
            </td>
            <th width="60" align="center">民族</th>
            <td align="center">
              {{ form.patientBaseInfoVo.nation }}
            </td>
          </tr>
          <tr>
            <th align="center">身高(cm)</th>
            <td align="center">
              {{ form.patientBaseInfoVo.patientHeight }}
            </td>
            <th align="center">体重(kg)</th>
            <td align="center" colspan="2">
              {{ form.patientBaseInfoVo.patientWeight }}
            </td>
            <th width="105" align="center">BMI(kg/m²)</th>
            <td colspan="2" align="center">
              {{ form.patientBaseInfoVo.patientBmi }}
            </td>
            <th align="center">费别</th>
            <td align="center">
              {{ feibie.dictLabel ? feibie.dictLabel : '' }}
            </td>
          </tr>
          <tr ref="zhusu">
            <th align="center">主诉</th>
            <td width="100" colspan="9">
              <div>{{ form.selfReported }}</div>
            </td>
          </tr>
          <tr>
            <th align="center">不良嗜好</th>
            <td width="100" colspan="9">
              <el-radio-group v-model="form.isHaveBadHobby">
                <el-radio :label="'0'" disabled>无</el-radio>
                <el-radio :label="'1'" disabled>有</el-radio>
              </el-radio-group>
              <div class="r buliangshihao" v-show="form.isHaveBadHobby == 1">
                <div class="r">
                  <el-radio v-model="form.isWine" :label="'1'" disabled
                  >酒
                  </el-radio
                  >
                  <div class="r" style="margin-right: 8px">
                    <el-input
                      style="width: 80px"
                      v-model="form.wineYear"
                      placeholder=""
                      disabled
                    />
                    <span class="ml5">年</span>
                  </div>
                  <div class="r">
                    <el-input
                      disabled
                      style="width: 80px"
                      v-model="form.wineAmountPerDay"
                      placeholder=""
                    />
                    <span class="ml5">两/天</span>
                  </div>
                </div>
                <div class="ml80">
                  <el-radio v-model="form.isSmoke" :label="'1'" disabled
                  >烟
                  </el-radio>
                  <div style="display: inline-block; margin-right: 8px">
                    <el-input
                      disabled
                      style="width: 80px"
                      v-model="form.smokeYear"
                      placeholder=""
                    />
                    <span class="ml5 mr5">年</span>
                    <el-input
                      disabled
                      style="width: 80px"
                      v-model="form.smokeAmountPerDay"
                      placeholder=""
                    />
                    <span class="ml5">支/天</span>
                  </div>
                </div>
              </div>
              <div
                style="display: inline-block"
                v-show="form.isHaveBadHobby == 1"
              >
                <el-radio v-model="form.isEat" :label="'1'" disabled
                >饮食
                </el-radio
                >
                <div class="buliangshihao" style="display: inline-block">
                  <el-input
                    disabled
                    style="width: 285px"
                    v-model="form.eatBadHobby"
                    placeholder=""
                  />
                </div>
              </div>
              <div
                style="display: inline-block; margin-left: 5px"
                v-show="form.isHaveBadHobby == 1"
              >
                <el-radio v-model="form.isOther" :label="'1'" disabled
                >其他
                </el-radio
                >
                <div class="buliangshihao" style="display: inline-block">
                  <el-input
                    disabled
                    style="width: 285px"
                    v-model="form.otherBadHobby"
                    placeholder=""
                  />
                </div>
              </div>
            </td>
          </tr>
          <tr>
            <th align="center">现病史及现病史用药汇总</th>
            <td colspan="9" style="padding: 0px">
              <div class="buliangshihao" style="padding: 10px">
                {{ form.medicalHistoryNow }}
              </div>
              <div class="yaoxuejianhu">
                <table align="center" width="920px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc">原发病</th>
                    <th style="border-top: 1px solid #ccc">药物名称</th>
                    <th style="border-top: 1px solid #ccc">用法用量</th>
                    <th style="border-top: 1px solid #ccc">最后用药时间</th>
                    <th style="border-top: 1px solid #ccc">是否继续使用</th>
                  </tr>
                  <template
                    v-if="
                      form.nowMedicalRecordVoList &&
                      form.nowMedicalRecordVoList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.nowMedicalRecordVoList"
                      :key="index"
                    >
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.purpose }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsName }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.amount }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsCycle }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.nowMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{
                          item.isContinue == 'Y'
                            ? '是'
                            : item.isContinue == 'N'
                            ? '否'
                            : ''
                        }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="5"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">既往病史及既往病史用药汇总</th>
            <td width="100" colspan="9" style="padding: 0px">
              <div class="" style="padding: 10px">
                {{ form.medicalHistoryBefore }}
              </div>
              <div class="yaoxuejianhu">
                <table align="center" width="920px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc">原发病</th>
                    <th style="border-top: 1px solid #ccc">药物名称</th>
                    <th style="border-top: 1px solid #ccc">用法用量</th>
                    <th style="border-top: 1px solid #ccc">最后用药时间</th>
                    <th style="border-top: 1px solid #ccc">是否继续使用</th>
                  </tr>
                  <template
                    v-if="
                      form.beforeMedicalRecordVoList &&
                      form.beforeMedicalRecordVoList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.beforeMedicalRecordVoList"
                      :key="index"
                    >
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.purpose }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsName }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.amount }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{ item.pillsCycle }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.beforeMedicalRecordVoList.length - 1
                            ? 'border-bottom: none !important;'
                            : ''
                        "
                      >
                        {{
                          item.isContinue == 'Y'
                            ? '是'
                            : item.isContinue == 'N'
                            ? '否'
                            : ''
                        }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="5"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
            </td>
          </tr>
          <tr>
            <th align="center">过敏史及处置史</th>
            <td width="100" colspan="9">
              <el-radio-group v-model="form.isHaveAllergy" disabled>
                <el-radio :label="'0'">无</el-radio>
                <el-radio :label="'1'">有</el-radio>
              </el-radio-group>
              <div class="buliangshihao" v-show="form.isHaveAllergy == 1">
                <div class="r">
                  <span class="mr10">怀疑药物/食物名称</span>
                  <el-input
                    style="width: 250px"
                    disabled
                    v-model="form.doubtPillsOrFoodName"
                    placeholder=""
                  />
                </div>
                <div class="r mb10">
                  <span class="mr10">主要ADR临床表现</span>
                  <el-input
                    style="width: 250px"
                    disabled
                    v-model="form.adrClinicFeature"
                    placeholder=""
                  />
                </div>
                <div class="r">
                  <span style="display: inline-block; width: 190px"
                  >处理措施及结果</span
                  >
                  <el-checkbox-group v-model="form.disposeAndResult" disabled>
                    <el-row>
                      <el-col
                        :span="8"
                        v-for="item in disposeResult"
                        :key="item.id"
                      >
                        <el-checkbox
                          style="font-size: 13px"
                          :label="item.dictValue"
                          class="region-list-item"
                        >{{
                            item.dictLabel
                          }}
                          <el-input
                            v-if="item.dictLabel == '其他'"
                            style="width: 285px; display: inline"
                            v-model="form.otherDisposeAndResult"
                            placeholder=""
                          />
                        </el-checkbox>
                      </el-col>
                    </el-row>
                  </el-checkbox-group>
                </div>
                <div class="r">
                  <el-radio
                    class="mr10"
                    v-model="form.isOtherDisposeAndResult"
                    :label="'1'"
                    disabled
                  >其他
                  </el-radio
                  >
                  <el-input
                    disabled
                    style="width: 250px"
                    v-model="form.otherDisposeAndResult"
                    placeholder=""
                  />
                </div>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">家族史</th>
            <td width="100" colspan="9">
              <div>{{ form.familyHistory }}</div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">个人史</th>
            <td width="100" colspan="9">
              <div>{{ form.personHistory }}</div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">入院诊断</th>
            <td colspan="9">
              <div style="display: flex; justify-content: space-between">
                <div style="width: 80px">西医诊断：</div>
                <div style="width: 91%">
                  {{ form.admittingDiagnosisWestern }}
                </div>
              </div>
              <div style="display: flex; margin-top: 5px">
                <span>中医诊断：</span>
                <div>
                  <div
                    v-for="(item, index) in form.traditionalDiagnosisVoList"
                    :key="index"
                  >
                    <div
                      :style="index !== 0 ? 'margin-top: 7px' : ''"
                      style="display: flex"
                    >
                      <div>{{ index + 1 }}、</div>
                      <div>
                        <span>病：</span>
                        {{ item.illnessName }}
                        <div style="margin-top: 5px">
                          <span>证：</span>
                          {{ item.patternOfSyndrome }}
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">初始药物治疗方案汇总</th>
            <td colspan="9" style="padding: 0px">
              <div class="yaoxuejianhu">
                <table align="center" width="920px" cellspacing="0">
                  <tr>
                    <th>药物名称(通用名称)</th>
                    <th style="width: 85px">单次剂量</th>
                    <th style="width: 85px">用法</th>
                    <th style="width: 85px">频次</th>
                    <th style="width: 105px">起始日期</th>
                  </tr>
                  <template
                    v-if="
                      form.initalMedicalRecordVoList &&
                      form.initalMedicalRecordVoList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.initalMedicalRecordVoList"
                      :key="index"
                    >
                      <td align="center">{{ item.pillsName }}</td>
                      <td align="center">{{ item.amountPer }}</td>
                      <td align="center">{{ item.pillsUsage }}</td>
                      <td align="center">{{ item.frequency }}</td>
                      <td align="center">
                        {{ item.beginDate ? item.beginDate.split(' ')[0] : '' }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="5"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <div class="yaoxuejianhu mt10">
                <table align="center" width="920px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc">
                      药物名称(通用名称)
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      用法用量
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 105px">
                      起始日期
                    </th>
                  </tr>
                  <template
                    v-if="
                      form.initTraditionalMedicalList &&
                      form.initTraditionalMedicalList.length > 0
                    "
                  >
                    <tr
                      v-for="(item, index) in form.initTraditionalMedicalList"
                      :key="index + 'haha'"
                    >
                      <td
                        align="center"
                        style="white-space: pre-wrap"
                        :style="
                          index == form.initTraditionalMedicalList.length - 1
                            ? 'border-bottom:none !important'
                            : ''
                        "
                      >
                        {{ item.pillsName }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.initTraditionalMedicalList.length - 1
                            ? 'border-bottom:none !important'
                            : ''
                        "
                      >
                        {{ item.pillsUsage }}
                      </td>
                      <td
                        align="center"
                        :style="
                          index == form.initTraditionalMedicalList.length - 1
                            ? 'border-bottom:none !important'
                            : ''
                        "
                      >
                        {{ item.beginDate ? item.beginDate.split(' ')[0] : '' }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr
                      align="center"
                      style="padding: 5px; border-bottom: none"
                    >
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="3"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <el-table
                v-if="false"
                class="chushiyaowuzhenliao"
                :data="form.initalMedicalRecordVoList"
                key="initalMedicalRecordVoList"
                style="width: 100%"
                :cell-class-name="isRender"
                ref="multipleTable2"
                row-key="orderItemId"
                border
                :default-expand-all="false"
                :tree-props="{
                  children: 'childMedicalRecordList',
                  hasChildren: 'hasChildren',
                }"
              >
                <el-table-column
                  prop="pillsName"
                  label="药物名称"
                  fixed
                  align="center"
                >
                </el-table-column>
                <el-table-column
                  align="center"
                  prop="amountPer"
                  label="单次剂量"
                >
                </el-table-column>
                <el-table-column align="center" prop="pillsUsage" label="用法">
                </el-table-column>
                <el-table-column align="center" prop="frequency" label="频次">
                </el-table-column>
                <el-table-column
                  prop="beginDate"
                  label="起始日期"
                  align="center"
                >
                </el-table-column>
              </el-table>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">药学评估结果</th>
            <td width="100" colspan="9">
              <div class="pl5">
                <div>
                  患者一般情况评估结果：{{ queryParams.generalConditionScore }}
                </div>
              </div>
              <div class="pl5 mt10">
                <div>
                  患者生活方式评估结果：{{ queryParams.liveStyleScore }}
                </div>
              </div>
              <div class="pl5 mt10">
                <div>
                  既往用药依从性评估结果：{{ queryParams.eatPillsHobbyScore }}
                </div>
              </div>
              <div class="pl5 mt10">
                <div>
                  一般医药知识评估结果：{{ queryParams.generalPillsScore }}
                </div>
                <div class="mt10">总分：{{ queryParams.totalScore }}</div>
              </div>
              <div class="mt10 pl5 r">
                <div>药学评估结论：</div>
                <span
                  style="font-size: 16px"
                  v-if="queryParams.selfCareAbilityLabel"
                >
                  <div>
                    {{
                      queryParams.totalScore > 80
                        ? '良好'
                        : queryParams.totalScore >= 60
                        ? '合格'
                        : '不合格'
                    }}
                  </div>
                </span>
              </div>
            </td>
          </tr>
          <tr>
            <th width="100" align="center">药学监护计划</th>
            <td width="100" colspan="9">
              <div class="b" style="margin-bottom: 5px">药学监护计划</div>
              <span style="white-space: pre-wrap">{{
                  form.medicalGuardianSchedule
                }}</span>
            </td>
          </tr>
        </table>
      </div>

      <!-- 药学监护记录 -->
      <div style="width: 1051px">
        <h3 style="text-align: center; font-weight: 900; font-size: 19px">
          药学监护记录
        </h3>
        <div
          style="border: 1px solid #ccc"
          v-if="
            pharmaceuticalCare.pharmaceuticalCareDetailVoList &&
            pharmaceuticalCare.pharmaceuticalCareDetailVoList.length > 0
          "
        >
          <div
            :class="index !== 0 ? '' : ''"
            v-for="(
              item, index
            ) in pharmaceuticalCare.pharmaceuticalCareDetailVoList"
            :key="index"
            class="buliangshihao"
          >
            <div class="" style="padding: 10px">
              <span>日期：{{ item.careDate }}</span
              ><span class="ml15">入院第 {{ item.inHospitalDays }} 天</span>
              <span class="ml15">药学监护级别：</span
              >
              <span>
                {{
                  {
                    0: '一级',
                    1: '二级',
                    2: '三级'
                  }[item.guardianLevel] || ''
                }}
            </span>
            </div>
            <div class="" style="padding: 10px">
              <span class="mb5" style="display: inline-block">生命体征：</span>
              <div v-if="item.vitalSigns" style="white-space: pre-wrap">
                {{ item.vitalSigns }}
              </div>
              <div v-else>体温、心率、呼吸、血压为必填项</div>
            </div>
            <div class="" style="padding: 10px">
              <span class="mb5" style="display: inline-block"
              >监护计划执行情况：</span
              >
              <div v-if="item.executiveCondition" style="white-space: pre-wrap">
                {{ item.executiveCondition }}
              </div>
              <div v-else>
                根据制定的监护计划，记录患者的病情变化、合理用药情况、医保费用和其他药事管理指标变化情况等
              </div>
            </div>
            <div class="">
              <span class="mb5 ml10" style="display: inline-block"
              >药物治疗方案调整：</span
              >
              <div class="yaoxuejianhu">
                <table align="center" width="1050px" cellspacing="0">
                  <tr>
                    <th
                      align="center"
                      style="border-top: 1px solid #ccc; width: 85px"
                    >
                      用药调整
                    </th>
                    <th align="center" style="border-top: 1px solid #ccc">
                      药物名称
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      单次剂量
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      用法
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      频次
                    </th>
                    <th
                      align="center"
                      style="border-top: 1px solid #ccc; width: 105px"
                    >
                      起始日期
                    </th>
                  </tr>
                  <template
                    v-if="
                      item.careDetailMedicalList &&
                      item.careDetailMedicalList.length > 0
                    "
                  >
                    <tr
                      v-for="(val, index) in item.careDetailMedicalList"
                      :key="index"
                    >
                      <td align="center">{{ val.purpose }}</td>
                      <td align="center">{{ val.pillsName }}</td>
                      <td align="center">{{ val.amountPer }}</td>
                      <td align="center">{{ val.pillsUsage }}</td>
                      <td align="center">{{ val.frequency }}</td>
                      <td align="center">
                        {{ val.beginDate ? val.beginDate.split(' ')[0] : '' }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr align="center" style="padding: 5px">
                      <td
                        align="center"
                        style="color: #ccc; border-bottom: none !important"
                        colspan="6"
                      >
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
              <div class="yaoxuejianhu mt20">
                <table align="center" width="1050px" cellspacing="0">
                  <tr>
                    <th style="border-top: 1px solid #ccc; width: 85px">
                      用药调整
                    </th>
                    <th style="border-top: 1px solid #ccc; width: 60%">
                      药物名称(通用名称)
                    </th>
                    <th style="border-top: 1px solid #ccc">用法用量</th>
                    <th style="border-top: 1px solid #ccc">起始日期</th>
                    <!-- <th style="border-top: 1px solid #ccc">结束日期</th> -->
                  </tr>
                  <template
                    v-if="
                      item.traditionalMedicalList &&
                      item.traditionalMedicalList.length > 0
                    "
                  >
                    <tr
                      v-for="(value, index) in item.traditionalMedicalList"
                      :key="index + 'xihaha'"
                    >
                      <td align="center">
                        {{ value.purpose ? value.purpose : '' }}
                      </td>
                      <td align="center" style="white-space: pre-wrap">
                        {{ value.pillsName }}
                      </td>
                      <td align="center">{{ value.pillsUsage }}</td>
                      <td align="center">
                        {{
                          value.beginDate ? value.beginDate.split(' ')[0] : ''
                        }}
                      </td>
                    </tr>
                  </template>
                  <template v-else>
                    <tr align="center" style="padding: 5px">
                      <td align="center" style="color: #ccc" colspan="4">
                        暂无数据
                      </td>
                    </tr>
                  </template>
                </table>
              </div>
            </div>
            <div class="" style="padding: 10px">
              <span class="mb5" style="display: inline-block"
              >药物监护计划调整：</span
              >
              <div v-if="item.carePlanAdjustment" style="white-space: pre-wrap">
                {{ item.carePlanAdjustment }}
              </div>
              <div v-else>治疗方案调整时针对增加的药物</div>
            </div>
          </div>
        </div>
        <div style="border: 1px solid #ccc; padding: 10px" v-else>
          <el-empty :image-size="100"></el-empty>
        </div>
      </div>

      <!-- 出院用药教育 -->
      <div style="width: 1051px">
        <h3 style="text-align: center; font-weight: 900; font-size: 19px">
          出院用药教育
        </h3>
        <div style="border: 1px solid #ccc">
          <div class="yaoxuejianhu">
            <h4 class="b ml10" style="margin-top: 10px; margin-bottom: 10px">
              出院用药：
            </h4>
            <table align="center" width="1050px" cellspacing="0">
              <tr>
                <th style="border-top: 1px solid #ccc">药物名称(通用名称)</th>
                <th style="width: 85px; border-top: 1px solid #ccc">
                  单次剂量
                </th>
                <th style="width: 85px; border-top: 1px solid #ccc">用法</th>
                <th style="width: 85px; border-top: 1px solid #ccc">频次</th>
                <th style="width: 105px; border-top: 1px solid #ccc">
                  用药周期
                </th>
              </tr>
              <template
                v-if="
                  pharmaceuticalCare.educWestMedicalRecordList &&
                  pharmaceuticalCare.educWestMedicalRecordList.length > 0
                "
              >
                <tr
                  v-for="(
                    item, index
                  ) in pharmaceuticalCare.educWestMedicalRecordList"
                  :key="index"
                >
                  <td align="center">{{ item.pillsName }}</td>
                  <td align="center">{{ item.amountPer }}</td>
                  <td align="center">{{ item.pillsUsage }}</td>
                  <td align="center">{{ item.frequency }}</td>
                  <td align="center">
                    {{ item.beginDate ? item.beginDate.split(' ')[0] : '' }}
                  </td>
                </tr>
              </template>
              <template v-else>
                <tr align="center" style="padding: 5px; border-bottom: none">
                  <td
                    align="center"
                    style="color: #ccc; border-bottom: none !important"
                    colspan="5"
                  >
                    暂无数据
                  </td>
                </tr>
              </template>
            </table>
            <table
              align="center"
              width="1050px"
              cellspacing="0"
              style="margin-top: 15px"
            >
              <tr>
                <th style="border-top: 1px solid #ccc">药物名称(通用名称)</th>
                <th style="border-top: 1px solid #ccc; width: 85px">
                  用法用量
                </th>
                <th style="border-top: 1px solid #ccc; width: 105px">
                  用药周期
                </th>
                <th style="border-top: 1px solid #ccc; width: 105px">
                  结束日期
                </th>
              </tr>
              <template
                v-if="
                  pharmaceuticalCare.educTraditionalMedicalRecordList &&
                  pharmaceuticalCare.educTraditionalMedicalRecordList.length > 0
                "
              >
                <tr
                  v-for="(
                    item, index
                  ) in pharmaceuticalCare.educTraditionalMedicalRecordList"
                  :key="index + 'haha'"
                >
                  <td align="center" style="white-space: pre-wrap">
                    {{ item.pillsName }}
                  </td>
                  <td align="center">{{ item.pillsUsage }}</td>
                  <td align="center">{{ item.pillsCycle }}</td>
                  <td align="center">
                    {{ item.endDate ? item.endDate.split(' ')[0] : '' }}
                  </td>
                </tr>
              </template>
              <template v-else>
                <tr align="center" style="padding: 5px; border-bottom: none">
                  <td
                    align="center"
                    style="color: #ccc; border-bottom: none !important"
                    colspan="4"
                  >
                    暂无数据
                  </td>
                </tr>
              </template>
            </table>
          </div>
          <div style="padding: 10px">
            <div>
              根据患者出院时病情和用药情况详实记录对患者的用药教育内容。
            </div>
            <div class="mt5 mb5">主要包含以下几方面:</div>
            <div style="white-space: pre-wrap">
              {{ pharmaceuticalCare.dischargePharmacyEducation }}
            </div>
          </div>
        </div>
      </div>

      <!-- 药学监护小结 -->
      <div style="width: 1050px">
        <h3 style="text-align: center; font-weight: 900; font-size: 19px">
          药历小结
        </h3>
        <div>
          <div
            style="
              border-top: 1px solid #ccc;
              border-left: 1px solid #ccc;
              border-right: 1px solid #ccc;
              padding: 10px;
            "
          >
            <span>入院日期</span
            ><span class="ml10">{{
              parseTime(form.patientBaseInfoVo.admissionTime, '{y}-{m}-{d}')
            }}</span>
            <span class="ml20">出院日期</span
            ><span class="ml10">{{
              parseTime(form.patientBaseInfoVo.dischargeTime, '{y}-{m}-{d}')
            }}</span>
            <span class="ml20">住院天数</span
            ><span class="ml10">{{ yaoLiXiaoJieList.inHospitalDays }} 天</span>
          </div>
          <table
            border="1"
            cellspacing="0"
            align="center"
            width="1050"
            bordercolor="#ccc"
          >
            <tr>
              <th width="65">出院记录</th>
              <td>
                <div class="b">出院诊断：</div>
                <div style="display: flex; margin-left: 20px; margin-top: 10px">
                  <div style="width: 86px">西医诊断：</div>
                  <div style="width: 92%">
                    {{ yaoLiXiaoJieList.admittingDiagnosisWestern }}
                  </div>
                </div>
                <div style="display: flex; margin-left: 20px; margin-top: 10px">
                  <span>中医诊断：</span>
                  <div>
                    <div
                      v-for="(
                        item, index
                      ) in yaoLiXiaoJieList.traditionalDiagnosisVoList"
                      :key="index"
                    >
                      <div
                        :style="index !== 0 ? 'margin-top: 7px' : ''"
                        style="display: flex"
                      >
                        <div>{{ index + 1 }}、</div>
                        <div>
                          <span>病：</span>
                          {{ item.illnessName }}
                          <div style="margin-top: 5px">
                            <span>证：</span>
                            {{ item.patternOfSyndrome }}
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </td>
            </tr>
            <tr>
              <th>住院期间治疗药物汇总</th>
              <td style="padding: 0px">
                <el-table
                  v-if="false"
                  class="chushiyaowuzhenliao"
                  :data="yaoLiXiaoJieList.medicalRecordVoList"
                  key="medicalRecordVoList"
                  style="width: 100%"
                  :cell-class-name="isRender"
                  ref="multipleTable2"
                  row-key="orderItemId"
                  border
                  :default-expand-all="false"
                  :tree-props="{
                    children: 'childMedicalRecordList',
                    hasChildren: 'hasChildren',
                  }"
                >
                  <el-table-column
                    prop="pillsName"
                    label="药物名称"
                    fixed
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="amountPer"
                    label="单次剂量"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pillsUsage"
                    label="用法"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="purpose"
                    label="用药目的"
                    fixed
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column align="center" prop="frequency" label="频次">
                  </el-table-column>
                  <el-table-column
                    prop="beginDate"
                    label="开始日期"
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="endDate"
                    label="结束日期"
                    align="center"
                  >
                  </el-table-column>
                </el-table>
                <div class="yaoxuejianhu">
                  <table align="center" width="983" cellspacing="0">
                    <tr>
                      <th align="center">药物名称(通用名称)</th>
                      <th>单次剂量</th>
                      <th>用法</th>
                      <th>频次</th>
                      <th align="center">起止日期</th>
                    </tr>
                    <template
                      v-if="
                        yaoLiXiaoJieList.medicalRecordVoList &&
                        yaoLiXiaoJieList.medicalRecordVoList.length > 0
                      "
                    >
                      <tr
                        v-for="(
                          item, index
                        ) in yaoLiXiaoJieList.medicalRecordVoList"
                        :key="index"
                      >
                        <td align="center">{{ item.pillsName }}</td>
                        <td align="center">{{ item.amountPer }}</td>
                        <td align="center">{{ item.pillsUsage }}</td>
                        <td align="center">{{ item.frequency }}</td>
                        <td align="center">
                          {{
                            item.beginDate && item.endDate
                              ? item.beginDate.split(' ')[0] +
                              '—' +
                              item.endDate.split(' ')[0]
                              : ''
                          }}
                        </td>
                      </tr>
                    </template>
                    <template v-else>
                      <tr
                        align="center"
                        style="padding: 5px; border-bottom: none"
                      >
                        <td
                          align="center"
                          style="color: #ccc; border-bottom: none !important"
                          colspan="5"
                        >
                          暂无数据
                        </td>
                      </tr>
                    </template>
                  </table>
                </div>
                <div class="yaoxuejianhu mt20">
                  <table align="center" width="983px" cellspacing="0">
                    <tr>
                      <th style="border-top: 1px solid #ccc; width: 60%">
                        药物名称(通用名称)
                      </th>
                      <th style="border-top: 1px solid #ccc">用法用量</th>
                      <th style="border-top: 1px solid #ccc">起始日期</th>
                    </tr>
                    <template
                      v-if="
                        yaoLiXiaoJieList.summaryTraditionalMedicalRecordList &&
                        yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                          .length > 0
                      "
                    >
                      <tr
                        v-for="(
                          item, index
                        ) in yaoLiXiaoJieList.summaryTraditionalMedicalRecordList"
                        :key="index + 'haha'"
                      >
                        <td
                          align="center"
                          style="white-space: pre-wrap"
                          :style="
                            index ==
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                              ? 'border-bottom: none !important;'
                              : ''
                          "
                        >
                          {{ item.pillsName }}
                        </td>
                        <td
                          align="center"
                          :style="
                            index ==
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                              ? 'border-bottom: none !important;'
                              : ''
                          "
                        >
                          {{ item.pillsUsage }}
                        </td>
                        <td
                          align="center"
                          :style="
                            index ==
                            yaoLiXiaoJieList.summaryTraditionalMedicalRecordList
                              .length -
                              1
                              ? 'border-bottom: none !important;'
                              : ''
                          "
                        >
                          {{
                            item.beginDate && item.endDate
                              ? item.beginDate.split(' ')[0] +
                              '—' +
                              item.endDate.split(' ')[0]
                              : ''
                          }}
                        </td>
                      </tr>
                    </template>
                    <template v-else>
                      <tr
                        align="center"
                        style="padding: 5px; border-bottom: none"
                      >
                        <td
                          align="center"
                          style="color: #ccc; border-bottom: none !important"
                          colspan="3"
                        >
                          暂无数据
                        </td>
                      </tr>
                    </template>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <th>合理用药情况汇总</th>
              <td>
                <template v-if="yaoLiXiaoJieList.medicationSummaryOption">
                  <div>{{ yaoLiXiaoJieList.reasonableMedicationSummary }}</div>
                  <span v-if="!yaoLiXiaoJieList.reasonableMedicationSummary"
                  >汇总患者住院医嘱前置审核中所有需要医师双签的内容</span
                  >
                </template>
              </td>
            </tr>
            <tr>
              <th>医保费用指标汇总</th>
              <td style="padding: 0px">
                <div class="yaoxuejianhu">
                  <table align="center" width="983" cellspacing="0">
                    <tr align="center">
                      <th width="420">指标</th>
                      <th>结果</th>
                    </tr>
                    <tr align="center">
                      <td>住院患者药品使用金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.pharmaceuticalAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td style="border-bottom: none !important">
                        住院患者自费药品使用金额占比
                      </td>
                      <td style="border-bottom: none !important">
                        {{ yaoLiXiaoJieList.selfPharmaceuticalAmountPercent }}
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <th>其他药事管理指标汇总</th>
              <td style="padding: 0px">
                <div class="yaoxuejianhu">
                  <table align="center" width="983" cellspacing="0">
                    <tr align="center">
                      <th width="420">指标</th>
                      <th>结果</th>
                    </tr>
                    <tr align="center">
                      <td>住院患者抗菌药物使用强度</td>
                      <td>{{ yaoLiXiaoJieList.antisepsisStrength }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者特殊使用级抗菌药物使用量占比</td>
                      <td>{{ yaoLiXiaoJieList.specialAntisepsisPercent }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者抗菌药物治疗前微生物检验样本送检情况</td>
                      <td>{{ yaoLiXiaoJieList.microorganismSample }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者基本药物使用金额占比（不包括中药饮片）</td>
                      <td>
                        {{ yaoLiXiaoJieList.baseMedicationAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td>住院患者基本药物使用品种数情况（不包括中药饮片）</td>
                      <td>{{ yaoLiXiaoJieList.baseMedicationNumCondition }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者集中带量采购品种使用金额占比</td>
                      <td>{{ yaoLiXiaoJieList.purchaseAmountPercent }}</td>
                    </tr>
                    <tr align="center">
                      <td>住院患者使用中药金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.traditionalPillsAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td>住院患者使用中药饮片金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.traditionalDrinkAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td>住院患者使用本院中药制剂金额占比</td>
                      <td>
                        {{ yaoLiXiaoJieList.traditionalThisAmountPercent }}
                      </td>
                    </tr>
                    <tr align="center">
                      <td style="border-bottom: none !important">
                        住院患者药品（不含中药饮片）使用金额占比情况
                      </td>
                      <td style="border-bottom: none !important">
                        {{ yaoLiXiaoJieList.pillsAmountPercent }}
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { history } from '@/api/workstation/baseInfo'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {
  listUser,
  getUser,
  delUser,
  addUser,
  updateUser,
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect
} from '@/api/system/user'
import {
  getBaseInfo,
  addBaseInfo,
  updateBaseInfo,
  leave,
  medicationRecordGet,
  medicalRecodeNo,
  medicationRecordPost
} from '@/api/workstation/baseInfo'
import {
  listTemplateInfo,
  getTemplateInfo,
  delTemplateInfo,
  addTemplateInfo,
  updateTemplateInfo
} from '@/api/workstation/templateInfo//templateInfo.js'
import {
  listPharmaceuticalCare,
  getPharmaceuticalCare,
  delPharmaceuticalCare,
  addPharmaceuticalCare,
  updatePharmaceuticalCare
} from '@/api/workstation/pharmaceuticalCareDetail/pharmaceuticalCareDetail.js'
// 药历小结相关接口
import {
  listMedicationSummary,
  getMedicationSummary,
  delMedicationSummary,
  addMedicationSummary,
  updateMedicationSummary
} from '@/api/workstation/medicationSummary/medicationSummary.js'
import Back from '@/components/Back/index'

export default {
  name: 'historyMedicine',
  data() {
    return {
      downAllyaoLiXiaoLoading: false, // 下载按钮加载状态
      // 部门树选项
      deptOptions: [],
      guardianLevel: [], // 监护分级
      patientState: [], // 住院状态
      userSex: [], // 患者性别
      payWay: [], // 付费方式
      id: undefined, // 患者ID
      checkList: [], // 不良嗜好选中的数组
      disposeResult: [], // 过敏史处理措施及结果
      MedicationRecordLoading: false, // 药历首页保存按钮加载状态
      downMedicationRecordLoading: false, // 药历首页下载按钮加载状态
      style: '', // 右侧表单样式 距离顶部距离
      // 按钮loading
      buttonLoading: false,
      medicalRecordNo: '', // 路由传过来的药历号
      setDisabled: {
        // 返回禁用时间
        disabledDate(time) {
          return time.getTime() > Date.now() // 可选历史天、可选当前天、不可选未来天
          // return time.getTime() > Date.now() - 8.64e7;  // 可选历史天、不可选当前天、不可选未来天
          // return time.getTime() < Date.now() - 8.64e7;  // 不可选历史天、可选当前天、可选未来天
          // return time.getTime() < Date.now(); // 不可选历史天、不可选当前天、可选未来天
        }
      },
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用药咨询表格数据
      medicationAdvisoryList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {
        patientBaseInfoVo: {},
        nowMedicalRecordVoList: [],
        beforeMedicalRecordVoList: [],
        initalMedicalRecordVoList: [],
        traditionalDiagnosisVoList: [],
        disposeAndResult: [],
        medicalGuardianSchedule:
          '(1)病情变化（注：从患者疾病的临床表现（症状、体征）的变化包括中医望闻问切诊内容，辅助检查结果，等指标情况确定有效性和安全性的监护时间和方法等。用药期间有无新发症状是否与药物存在相关性等安全性。)(2)合理用药情况（注：主要记录患者住院医嘱前置审核中需要医师双签的内容及个体化给药相关检测结果（如血药浓度监测和基因检测）并做简要分析评价。)(3)医保费用情况（注:统计患者药物治疗方案中各类药物的费用占比情况，包括药品使用金额占比和自费药品使用金额占比。)(4)其他药事管理指标（注：重点汇总分析每位患者治疗过程中的药物治疗方案是否满足医疗机构各项药事管理指标的要求。)'
      },
      // 表单校验
      rules: {
        id: [
          { required: true, message: '用药咨询ID不能为空', trigger: 'blur' }
        ],
        userName: [
          { required: true, message: '患者姓名不能为空', trigger: 'blur' }
        ],
        category: [
          { required: true, message: '类别不能为空', trigger: 'blur' }
        ],
        advisoryContent: [
          { required: true, message: '咨询内容不能为空', trigger: 'blur' }
        ],
        advisoryTime: [
          { required: true, message: '咨询时间不能为空', trigger: 'blur' }
        ],
        receiveManId: [
          { required: true, message: '出院时间ID不能为空', trigger: 'blur' }
        ],
        // receiveManName: [
        //   { required: true, message: "出院时间不能为空", trigger: "blur" },
        // ],
        receiveTime: [
          { required: true, message: '出院时间不能为空', trigger: 'blur' }
        ],
        isDispose: [
          { required: true, message: '是否处理不能为空', trigger: 'blur' }
        ],
        disposeContent: [
          { required: true, message: '处理内容不能为空', trigger: 'blur' }
        ],
        disposeTime: [
          { required: true, message: '处理时间不能为空', trigger: 'blur' }
        ]
      },
      dicts: ['advisory_category'],
      categoryList: [], // 字典类别数组
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        medicalRecordNo: this.$route.query.medicalRecordNo + ''
      },
      // 药历小结信息数据  开始 开始
      yaoLiXiaoJieList: {
        traditionalDiagnosisBoList: [],
        medicalRecordBoList: []
      },
      downyaoLiXiaoJieListLoading: false, // 下载药学监护小结按钮状态
      // 药历小结信息数据  结束 结束
      // 药学监护记录相关数据  开始 开始 开始
      pharmaceuticalCare: {
        pharmaceuticalCareDetailBoList: [],
        pharmaceuticalCareDetailVoList: []
      },
      downpharmaceuticalCareDetailVoListLoading: false, // 下载出院用药教育按钮状态
      downpharmaceuticalCareLoading: false, // 下载药学监护计划按钮状态
      templateList: {}, // 模板数据
      dischargePharmacyEducation: '' // 出院用药教育
      // 药学监护记录相关数据  结束 结束
    }
  },
  components: {
    Back,
    Treeselect
  },
  created() {
    this.medicalRecordNo = this.$route.query.medicalRecordNo + ''
    // 字典查询  过敏史处理措施及结果
    this.getDicts('dispose_and_result').then((res) => {
      this.disposeResult = res.data.filter((item) => {
        return item.dictLabel !== '其他'
      })
    })
    this.getList()
    // 先获取药历首页信息详细信息
    this.getYaoLiShouYeList()
    // 先获取药学监护记录详细信息
    this.getYaoXueJianHuList()
    // 先获取药历小结详细信息
    this.getYaoLiXiaoJieList()
    this.getDeptTree()
  },
  computed: {
    // 动态计算费别
    feibie() {
      return (
        this.payWay.find(
          (user) => user.dictValue === this.form.patientBaseInfoVo.payWay
        ) || ''
      )
    }
  },
  methods: {
    /** 查询科室下拉树结构 */
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data
      })
    },
    /** 查询历史列表 */
    getList() {
      this.loading = true
      history(this.queryParams).then((response) => {
        console.log(response)
        this.medicationAdvisoryList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 获取药历首页信息详细信息
    getYaoLiShouYeList() {
      this.dataloading = true
      medicationRecordGet(this.medicalRecordNo).then((res) => {
        if (res.data !== null) {
          console.log('9999999999', res.data)
          this.form = res.data
          this.form.patientBaseInfoVo = res.data.patientBaseInfoVo
            ? res.data.patientBaseInfoVo
            : {}
          this.form.nowMedicalRecordVoList = res.data.nowMedicalRecordVoList
            ? res.data.nowMedicalRecordVoList
            : []
          this.form.beforeMedicalRecordVoList = res.data
            .beforeMedicalRecordVoList
            ? res.data.beforeMedicalRecordVoList
            : []
          this.form.initalMedicalRecordVoList = res.data
            .initalMedicalRecordVoList
            ? res.data.initalMedicalRecordVoList
            : []
          this.form.traditionalDiagnosisVoList = res.data
            .traditionalDiagnosisVoList
            ? res.data.traditionalDiagnosisVoList
            : []
          this.form.disposeAndResult = res.data.disposeAndResult
            ? [...res.data.disposeAndResult]
            : []
          // 药学监护计划默认可编辑模板
          if (!res.data.medicalGuardianSchedule) {
            this.form.medicalGuardianSchedule =
              '(1)病情变化（注：从患者疾病的临床表现（症状、体征）的变化包括中医望闻问切诊内容，辅助检查结果，等指标情况确定有效性和安全性的监护时间和方法等。用药期间有无新发症状是否与药物存在相关性等安全性。)(2)合理用药情况（注：主要记录患者住院医嘱前置审核中需要医师双签的内容及个体化给药相关检测结果（如血药浓度监测和基因检测）并做简要分析评价。)(3)医保费用情况（注:统计患者药物治疗方案中各类药物的费用占比情况，包括药品使用金额占比和自费药品使用金额占比。)(4)其他药事管理指标（注：重点汇总分析每位患者治疗过程中的药物治疗方案是否满足医疗机构各项药事管理指标的要求。)'
          }
          this.dataloading = false
        }
      })
      //  先获取是否评估过
      medicalRecodeNo(this.medicalRecordNo).then((res) => {
        if (res.data !== null) {
          this.queryParams = res.data
          console.log(this.queryParams)
        }
      })
    },
    // 药学监护记录相关   开始 开始
    getYaoXueJianHuList() {
      getPharmaceuticalCare(this.medicalRecordNo).then((response) => {
        if (response.data !== null) {
          this.pharmaceuticalCare = response.data
          if (!response.data.dischargePharmacyEducation) {
            this.pharmaceuticalCare.dischargePharmacyEducation =
              '①患者药物治疗和疾病发展现状及其预后;②出院用药注意事项，包括药物的服用周期、用法用量、潜在的药物不良反应及预防和处理方法、药物与药物之间或药物与食物之间的相互作用等;③患者应定期蹬测的指标与复查网期;④出院后的生活方式及注意事项;⑤需随访患者的药学随访计划;'
          }
          this.pharmaceuticalCare.pharmaceuticalCareDetailVoList = response.data
            .pharmaceuticalCareDetailVoList
            ? response.data.pharmaceuticalCareDetailVoList
            : []
        }
      })
    },
    // 查询该患者药历小结详细信息
    getYaoLiXiaoJieList() {
      getMedicationSummary(this.medicalRecordNo).then((response) => {
        console.log('[ 查询该患者药历小结详细信息 ] >', response)
        if (response.data !== null) {
          this.yaoLiXiaoJieList = response.data
          this.yaoLiXiaoJieList.medicalRecordVoList = response.data
            .medicalRecordVoList
            ? response.data.medicalRecordVoList
            : []
          this.yaoLiXiaoJieList.traditionalDiagnosisVoList = response.data
            .traditionalDiagnosisVoList
            ? response.data.traditionalDiagnosisVoList
            : []
        }
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        userName: undefined,
        category: undefined,
        advisoryContent: undefined,
        advisoryTime: undefined,
        receiveManId: undefined,
        receiveManName: undefined,
        receiveTime: undefined,
        isDispose: undefined,
        disposeContent: undefined,
        disposeTime: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加用药咨询'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.open = true
      this.title = '查看药历'
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          console.log(this.form)
          // return
          this.buttonLoading = true
          if (this.form.id != null) {
            updateMedicationAdvisory(this.form)
              .then((response) => {
                this.$modal.msgSuccess('修改成功')
                this.open = false
                this.getList()
              })
              .finally(() => {
                this.buttonLoading = false
              })
          } else {
            this.form.receiveManId = this.userId
            addMedicationAdvisory(this.form)
              .then((response) => {
                this.$modal.msgSuccess('新增成功')
                this.open = false
                this.getList()
              })
              .finally(() => {
                this.buttonLoading = false
              })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      row.moveHistory = 0 + '' // 移除药历  传值
      this.$modal
        .confirm(
          `是否确认删除患者 ${row.patientName} 在 ${row.admissionTime} 入院的历史药历吗`
        )
        .then(() => {
          this.loading = true
          return updateBaseInfo(row)
        })
        .then(() => {
          this.loading = false
          this.getList()
          this.$modal.msgSuccess('删除成功')
        })
        .catch(() => {
        })
        .finally(() => {
          this.loading = false
        })
    },
    // 下载历史药历
    downyaoLi() {
      this.downAllyaoLiXiaoLoading = true
      let time = this.form.patientBaseInfoVo.admissionTime.split(' ')[0] || ''
      console.log(time)
      this.$download.get(
        '/workstation/medicationRecord/overall/',
        this.medicalRecordNo,
        `${this.form.patientBaseInfoVo.patientName}—${time}.docx`
      )
      this.downAllyaoLiXiaoLoading = false
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        'workstation/medicationAdvisory/export',
        {
          ...this.queryParams
        },
        `medicationAdvisory_${new Date().getTime()}.xlsx`
      )
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body {
  font-size: 16px !important;
}

::v-deep .chushiyaowuzhenliao {
  .cell {
    display: flex;
    align-items: center;
  }
}

/* 隐藏多选框 */
::v-deep .disabled-column .el-checkbox__input {
  display: none;
}

::v-deep .el-dialog__body {
  max-height: 750px !important;
  overflow: auto;
  padding: 10px 20px;
}

.buliangshihao {
  ::v-deep .el-input__inner {
    border: none;
    border-radius: 0px;
    border-bottom: 1px solid #000;
  }

  //checkBox自定义禁用样式
  .el-checkbox__input.is-disabled + .el-checkbox__label {
    color: #808080 !important;
  }

  .el-checkbox__input.is-disabled.is-checked + .el-checkbox__label {
    color: #1890ff !important;
  }

  .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
    background-color: #1890ff !important;
    border-color: #1890ff !important;
  }

  //输入框 还有 textarea 禁用状态下颜色改变
  ::v-deep .el-input.is-disabled .el-input__inner,
  textarea:disabled {
    color: #606266;
    background-color: white;
  }
}

.label {
  ::v-deep .el-form-item__label {
    font-size: 14px;
    color: #aaaaaa;
    font-weight: normal;
  }
}

.label1 {
  ::v-deep .el-form-item__label {
    font-size: 16px;
    font-weight: normal;
    color: #000;
  }
}

.yaoxuejianhu {
  table tr th {
    border-right: 1px solid #ccc !important;
    border-bottom: 1px solid #ccc !important;
  }

  table tr th:last-child {
    border-right: none !important;
  }

  table tr td {
    // border-top: 1px solid #ccc !important;
    border-right: 1px solid #ccc !important;
    border-bottom: 1px solid #ccc !important;
  }

  table tr td:last-child {
    border-right: none !important;
  }
}

::v-deep .el-collapse-item__header {
  font-family: "Arial Negreta", "Arial Normal", "Arial", sans-serif;
  font-weight: 700;
  font-style: normal;
  font-size: 16px;
  text-align: center;
  height: 65px;
  padding-left: 55px;
  border: 1px solid rgba(242, 242, 242, 1);
  margin-top: 20px;
}

::v-deep .el-collapse-item__wrap {
  border: none;
}

::v-deep .el-collapse {
  border: none;
}

::v-deep .el-radio__label {
  padding-left: 7px;
}

::v-deep .el-radio {
  margin-right: 10px;
}

table > tr > th > div {
  // width: 100%;
  font-weight: normal;
}

table > tr > th {
  padding: 10px 10px 10px 10px;
}

table > tr > td {
  padding: 10px 10px 10px 10px;
}

.input {
  width: 620px;
  padding: 5px 10px;
  font-family: "Arial Normal", "Arial", sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 13px;
  letter-spacing: normal;
  color: #000000;
  vertical-align: none;
  text-align: left;
  text-transform: none;
  background-color: transparent;
  border-color: transparent;
  resize: none;
  border: 1px solid #dcdfe6;
  border-radius: 15px;
}

.value {
  display: inline-block;
  min-width: 60px;
  border-bottom: 1px solid #000;
  text-align: center;
  line-height: 30px;

  ::v-deep .vue-treeselect--disabled .vue-treeselect__control {
    border: none;
    background-color: #fff;
    display: flex;
    height: 30px;
  }

  ::v-deep .vue-treeselect__control-arrow-container {
    display: none;
  }

  ::v-deep .vue-treeselect {
    text-align: center;
  }
}

.headTxt {
  font-size: 18px;
  font-weight: 900;
}

table {
  border-collapse: collapse !important;
  border-color: #ccc !important;
  table-layout: fixed;
}

.el-textarea .el-input--medium {
  width: 100%;
}
</style>
